<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>userId</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='userId' type='text' name='userId' id='userId' data-bv-notempty='true' data-bv-notempty-message='userId 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>openid</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='openid' type='text' name='openid' id='openid' data-bv-notempty='true' data-bv-notempty-message='openid 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>nickname</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='nickname' type='text' name='nickname' id='nickname' data-bv-notempty='true' data-bv-notempty-message='nickname 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>headimgurl</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='headimgurl' type='text' name='headimgurl' id='headimgurl' data-bv-notempty='true' data-bv-notempty-message='headimgurl 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>sex</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='sex' type='text' name='sex' id='sex' data-bv-notempty='true' data-bv-notempty-message='sex 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>phone</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='phone' type='text' name='phone' id='phone' data-bv-notempty='true' data-bv-notempty-message='phone 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>province</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='province' type='text' name='province' id='province' data-bv-notempty='true' data-bv-notempty-message='province 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>city</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='city' type='text' name='city' id='city' data-bv-notempty='true' data-bv-notempty-message='city 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>country</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='country' type='text' name='country' id='country' data-bv-notempty='true' data-bv-notempty-message='country 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>createTime</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='createTime' type='text' name='createTime' id='createTime' data-bv-notempty='true' data-bv-notempty-message='createTime 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>updateTime</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='updateTime' type='text' name='updateTime' id='updateTime' data-bv-notempty='true' data-bv-notempty-message='updateTime 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>state</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='state' type='text' name='state' id='state' data-bv-notempty='true' data-bv-notempty-message='state 不能为空'>
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='tUserList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/tUsers/'+id,
					async : false,
					success : function(data) {
						$('#userId').val(data.userId);
						$('#openid').val(data.openid);
						$('#nickname').val(data.nickname);
						$('#headimgurl').val(data.headimgurl);
						$('#sex').val(data.sex);
						$('#phone').val(data.phone);
						$('#province').val(data.province);
						$('#city').val(data.city);
						$('#country').val(data.country);
						$('#createTime').val(data.createTime);
						$('#updateTime').val(data.updateTime);
						$('#state').val(data.state);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/tUsers',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "tUserList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
